export function mergeInfo(list, info) {
  const parsedInfo = []
  function getRootType(id) {
    let item = list.find(it => it.id === id)
    while (item.parent_id !== 0) {
      item = list.find(it => it.id === item.parent_id)
    }
    return item
  }
  for (const element of info) {
    const root = getRootType(element.question_type)
    let line = parsedInfo.find(it => it.question_type === root.id)
    if (!line) {
      line = {
        question_type: root.id,
        name: root.type_name,
        value: 0
      }
      parsedInfo.push(line)
    }
    line.value += element.num
  }
  return parsedInfo
}
